<template>
	<div class="home" :style="{paddingBottm:showBar?'50px':''}">
		<link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_1533371_cqye2fp3oe.css" />
		<!-- 轮播图 -->
		<van-swipe class="banner" :autoplay="3000" indicator-color="red">............
			<van-swipe-item v-for="(item,index) in bannerList" :key="index">
				<img :src="item.imageUrl" alt="">
			</van-swipe-item>
		</van-swipe>
		<!-- icon -->
		<div class="iconer">
			<button><i class="iconfont icon-meirituijian"></i></button>
			<button><i class="iconfont icon-gedan"></i></button>
			<button><i class="iconfont icon-paixingbang-copy"></i></button>
			<button><i class="iconfont icon-diantai"></i></button>
			<button><i class="iconfont icon-zhibo-copy-copy"></i></button>
		</div>
		<!-- 推荐歌单 -->
		<div class="songcenter">
			<p class="songLister"><b>推荐歌单</b></p>
			<button class="songListPlaza">歌单广场</button>
		</div>
		<div class="recommend" @click="recommendLink(item.id)" v-for="(item,index) in recommender.slice(0, 6)" :key="index">
			<img :src="item.picUrl" alt="">
			<p>{{item.name}}</p>
		</div>
		<!-- 新歌 新碟 -->
		<div class="newSongList">
			<div class="newSong"><b>新歌</b><b @click="">新碟</b></div>
			<div class="newDisc">
				<p>更多新碟</p>
			</div>
		</div>
		<div class="newSongBox" v-for="(item,index) in newestMusicList.slice(0,3)" :key="index">
			<img :src="item.picUrl" alt="">
			<p v-for="(it,idx) in item.song.artists" :key="idx">{{it.name}}</p>
			<p>{{item.name}}</p>
		</div>
		<!-- 最新mv -->
		<div class="recommendMusic">
			<p><b>最新mv</b></p>
		</div>
			<song></song>
	</div>
</template>

<script>
	import api from '../js/api.js'
	import song from '../components/song.vue'

	export default {
		data() {
			return {
				bannerList: [],
				recommender: [],
				newestMusicList: [],
			}
		},
		created() {
			this.axios({
				url: "/banner"
			}).then(res => {
				this.bannerList = res.data.banners;
			});
			this.axios({
				url: "/personalized"
			}).then(res => {
				this.recommender = res.data.result;
			});
			this.axios({
				url: api.personalizedMusic
			}).then(res => {
				// window.console.log(res)
				this.newestMusicList = res.data.result;
			});
		},
		methods: {
			recommendLink(id) {
				this.$router.push({
					path: '/List',
					query: {
						item: id
					}
				});
			},
		},
		computed: {
			showBar() {
				return this.$store.state.currnetSong.al.id
			},
		},
		components:{
			song
		}
	}
</script>

<style lang="scss" scoped>
	.home {
		.banner {
			width: 100%;
			margin-top: 10px;

			img {
				width: 100%;
			}
		}

		.iconer {
			border-bottom: 1px solid skyblue;

			button {
				width: 40px;
				height: 40px;
				margin: 7px 17px 10px 17px;
				border-radius: 50px;
				background-color: skyblue;

				.iconfont {
					font-size: 30px;
				}
			}
		}

		.songcenter {
			display: flex;
			justify-content: space-between;

			.songLister {
				height: 35px;
				line-height: 35px;
				text-align: left;
				margin-left: 5px;
			}

			.songListPlaza {
				width: 60px;
				height: 22px;
				font-size: 13px;
				margin: 5px;
				margin-top: 8px;
				border-radius: 10%;
				border: 1px solid #000000;
				background-color: white;
			}
		}

		.recommend {
			float: left;
			width: 120px;
			height: 150px;
			margin-right: 5px;

			img {
				width: 100%;
			}

			p {
				font-size: 13px;
				text-align: left;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}
		}

		.newSongList {
			width: 100%;
			height: 40px;
			display: flex;
			font-size: 14px;
			line-height: 40px;
			justify-content: space-between;
			border-top: 0.5px solid skyblue;

			.newSong {
				margin: 0 5px 0 5px;
			}

			.newDisc {
				width: 65px;
				height: 23px;
				float: right;
				font-size: 13px;
				margin: 10px 5px 0 0;
				border-radius: 10%;
				border: 0.5px solid #000000;

				p {
					margin-top: -10px;
				}
			}
		}

		.newSongBox {
			float: left;
			width: 120px;
			height: 160px;
			margin-right: 5px;
			overflow: hidden;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: nowrap;

			img {
				width: 100%;
			}

			p {
				float: left;
				margin: 0 5px 0 5px;
				font-size: 12px;
			}
		}

		.recommendMusic {
			width: 100%;
			height: 35px;
			float: left;
			border-top: 0.5px solid skyblue;

			p {
				float: left;
				margin-left: 5px;
				font-size: 15px;
				line-height: 35px;
			}
		}
	}
</style>
